/**
 * The main QML file.
 *
 * (c) Copyright 2011 Nokia Corporation. All rights reserved.
 */

import QtQuick 1.1
import com.nokia.symbian 1.1

Window {
    id: root;

    // Background image
    Image {
        id: backgroundImage;

        anchors.fill: parent;
        source: "qrc:/gfx/background_360x640.png";
    }

    // Status bar
    StatusBar {
        id: statusBar;
        anchors.top: parent.top;
        z: 1;
    }

    PageStack {
        id: pageStack;

        anchors {
            top: statusBar.bottom;
            left: parent.left;
            right: parent.right;
            bottom: toolBar.top;
        }

        toolBar: toolBar;

        Component.onCompleted: {
            pageStack.push(Qt.resolvedUrl("LatestView.qml"));
        }

    }

    BusyIndicator {
        id: busyIndicator;

        width: 40;
        height: 40;
        x: parent.width / 2 - width / 2;
        y: parent.height / 2 - height / 2;
        opacity: 0;
    }

    // Toolbar
    ToolBar {
        id: toolBar;

        anchors.bottom: parent.bottom;
    }

    ToolBarLayout {
        id: toolBarLayout;

        // Exit/Back button
        ToolButton {
            id: btnExitBack;
            iconSource: "toolbar-back";
            onClicked: Qt.quit();
        }

        // Controls for changing the current tab.
        ButtonRow {
            id: tabControls;

            // Latest button
            ToolButton {
                id: latestTabButton;
                iconSource: "qrc:/gfx/tb-popular.png";
                onClicked: {
                    busyIndicator.opacity = 1;
                    busyIndicator.running = true;
                    pageStack.replace(Qt.resolvedUrl("LatestView.qml"));
                }
            }

            // Popular button
            ToolButton {
                id: popularTabButton;
                iconSource: "qrc:/gfx/tb-latest.png";
                onClicked: {
                    busyIndicator.opacity = 1;
                    busyIndicator.running = true;
                    pageStack.replace(Qt.resolvedUrl("PopularView.qml"));
                }

            }

            // Search button
            ToolButton {
                id: searchTabButton;
                iconSource: "toolbar-search";
                onClicked: {
                    busyIndicator.opacity = 1;
                    busyIndicator.running = true;
                    pageStack.replace(Qt.resolvedUrl("SearchView.qml"));
                }
            }
        }
    }
}
